<template>
    <bi-input v-model="value" icon="fa-file-code-o" :loading="loading"  :after-width="130" readonly  placeholder="请选择模板" >
        <template #after>
            <bi-icon data="fa-ban" @click="clear" style="margin-right: 10px; cursor: pointer;" v-if="value"></bi-icon>
            <bi-button type="light" icon="fa-folder-open" @click="openDialog" >选择模板</bi-button>
        </template>
    </bi-input>
</template>


<script>
import fieldMixin from  '@@/admin/assets/bi-plug/fieldMixin.js';
export default{
    mixins:[fieldMixin],
    data(){
        return {
            loading:false
        }
    },
    methods:{
        openDialog(){
            this.loading = true;

            this.$ajax({
                url:this.$url({app:'web',controller:'admin.index',action:'getThemePath'}),
                success:(res)=>{
                    this.loading = false;
                    this.$admin.systemFile((value)=>{
                        this.value = value.file;
                    },{
                        title:'选择模板',
                        root:res.path,
                        ext:'html'
                    })
                },
                over:()=>{
                    this.loading = false;
                }
            });

        },
        clear(){
            this.value = '';
        }
    }
}

</script>